/***************************************************************************
*   Copyright (C) 2008 by Tyler Shaub   *
*   tyler.shaub@gmail.com   *
*                                                                         *
*   See COPYING	*
***************************************************************************/

#include "MemberVariables.hpp"

#include <vector>
#include <string>
#include <map>
#include <cassert>

#include <boost/typeof/typeof.hpp>
#include <boost/mpl/list.hpp>

#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/array.hpp>
#include <boost/preprocessor/array/elem.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>

#include <boost/noncopyable.hpp>

#include "CreateTypeInfo.hpp"

#include "AnyPtr.hpp"
#include "AnyCast.hpp"

namespace Flex_ {

MemberVariables::MemberVariables() : variables_()
{
}

void MemberVariables::SetVariables(MemberVariablePtrMap const& varPtrs)
{
	variables_ = varPtrs;
}

AnyPtr MemberVariables::GetMemberVariable(std::string const& memberName, AnyPtr const& object) const
{
	MemberVariablePtrIter i = variables_.find(memberName);
	if(i != variables_.end())
		return i->second->GetPointer(object);
	else
		return AnyPtr();
}

MemberVariables::MemberVariablePtrRange MemberVariables::GetAllMemberVariablePtrs() const
{
	return MemberVariablePtrRange(variables_.begin(), variables_.end());
}

bool MemberVariables::Empty() const
{
	return variables_.empty();
}

template < typename Func >
struct ForEachVar
{
	Func func_;
	ForEachVar(Func f) : func_(f) {}

	template <typename TypeList, typename Class>
	void ForEachVariable(Class & object, TypeList const& variables )
	{
		// foreach type, call func /w object->variable
	}

	template <typename TypeList, typename Class>
	void ForEachVariablePtr(Class & object, TypeList const& variables )
	{
		// foreach type, call func /w object and variable
	}

	template <typename TypeList, typename Class>
	void operator()(Class & object, TypeList const& variables )
	{
		ForEachVariable(object, variables);
	}

private:
	// struct+func for recursively calling?
	// bleh
};

} // Flex_



